<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>js 获取视频 demo</title>
<style type="text/css">
   .zhao{ 
  position: absolute;
 	left: 420px;
 	top :60px;
  }
</style>
    </head>
    <body onload="autoclick()">
      <form action="tttttt"> </form>
        <!-- 照相机 -->
        <video id="video" width="400" height="400" autoplay></video>
         <!-- 拍照事件 -->
        <button id="snap" name="zhaopian" style="display: none" ></button>     
        <!-- 图片 -->
         <div class="zhao">
        <canvas id="canvas"   width="400" height="400" ></canvas>
        </div>
        <div style="float: right;">
        <div style="width: 300px;height: 400px;overflow: auto;">
        	<h2>预约信息</h2>
        	<c:forEach items="${bespeaklist }" var="bespeaklist"> 
        		<div style="border: 1px solid red; ">
        		<marquee direction="up">
        			<table>
        				<tr>
        					<td>
        					           来访者姓名 : 
        					</td>
        					<td>
        						${bespeaklist.bname}
        					</td>
        				</tr>
        				<tr>
        					<td>
        						预计来访时间 : 
        					</td>
        					<td>
        						<fmt:formatDate value="${bespeaklist.btime}" type="date"/>
        					</td>
        				</tr>
        				<tr>
        					<td>
        						访问人 :
        					</td>
        					<td>
        						${bespeaklist.name}
        					</td>
        				</tr>
        				<tr>
        					<td>
        						访问人部门 :
        					</td>
        					<td>
        						${bespeaklist.sjob}
        					</td>
        				</tr>
        					<tr>
        					<td>
        						来访目的 :
        					</td>
        					<td>
        						${bespeaklist.bgoal}
        					</td>
        				</tr>
        			</table>
        			</marquee>
        		</div>
        	</c:forEach>
        </div>
        <div>
        		<form action="" method="post">
        			<input type="submit" value="添加新的预约信息">
        		</form>
        </div>
        </div>
        
        
        <div style="float: right;">
        <div style="width: 300px;height: 400px;overflow: auto;">
        	<h2>登记表</h2>
        	<c:forEach items="${registerlist }" var="registerlist"> 
        		<div style="border: 1px solid red; ">
        		<marquee direction="up">
        			<table>
        				<tr>
        					<td>
        					           姓名 : 
        					</td>
        					<td>
        						${registerlist.rname}
        					</td>
        				</tr>
        				<tr>
        					<td>
        						来访时间 : 
        					</td>
        					<td>
        						<fmt:formatDate value="${registerlist.rtime}" type="date"/>
        					</td>
        				</tr>
        				<tr>
        					<td>
        						登记人 :
        					</td>
        					<td>
        						${registerlist.sname}
        					</td>
        				</tr>
        				<tr>
        					<td>
        						来访目的 :
        					</td>
        					<td>
        						${registerlist.rcontent}
        					</td>
        				</tr>
        			</table>
        			</marquee>
        		</div>
        	</c:forEach>
        </div>
        <div>
        		<form action="" method="post">
        			<input type="submit" value="添加新的登记信息">
        		</form>
        </div>
        </div>
        
        
    </body>
    <script type="text/javascript">
    //定时拍照
    function myclick()
    {
    	document.getElementById("snap").click();
    }
    function autoclick(){
    	setInterval("myclick()",1000);
    }  
        // Put event listeners into place
        window.addEventListener("DOMContentLoaded", function() {
            // Grab elements, create settings, etc.
            var canvas = document.getElementById("canvas"),
                context = canvas.getContext("2d"), //getContext唯一合法值2d
                video = document.getElementById("video"),
                videoObj = {
                    "video": true,
                    "audio": true
                },
                errBack = function(error) {
                    console.log("Video capture error: ", error.code);
                };
            // Put video listeners into place
            //navigator.getUserMedia =  navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
            if (navigator.getUserMedia) { // Standard 如果用户允许打开摄像头
                //stream为读取的视频流
                navigator.getUserMedia(videoObj, function(stream) {
                    video.src = stream;
                    video.play();
                }, errBack);
            } else if (navigator.webkitGetUserMedia) { // WebKit-prefixed  根据不同的浏览器写法不同
                navigator.webkitGetUserMedia(videoObj, function(stream) {
                    video.src = window.webkitURL.createObjectURL(stream);
                    video.play();
                }, errBack);
            } else if (navigator.mozGetUserMedia) { // Firefox-prefixed
                navigator.mozGetUserMedia(videoObj, function(stream) {
                    video.src = window.URL.createObjectURL(stream);
                    video.play();
                }, errBack);
            }
            document.getElementById("snap").addEventListener("click", function() {
                context.drawImage(video, 0, 0, 300, 300);
            });
        }, false);
    </script>
<a href="dl">退出</a>
</html>